
def get_cookie(row, target):
    row_dict = {}
    for r in row.split('; '):
        try:
            equal_index = r.index('=')
        except ValueError:
            break
        row_dict[r[:equal_index]] = r[equal_index+1:]
    return row_dict[target]


get_cookie('theme=light; sessionToken=abc123', 'theme') == 'light'
get_cookie('_ga=GA1.2.447610749.1465220820; _gat=1; ffo=true', 'ffo') == 'true'

if __name__ == "__main__":
    # These "asserts" using only for self-checking and not necessary for
    # auto-testing
    assert get_cookie('theme=light; sessionToken=abc123',
                      'theme') == 'light', 'theme=light'
    assert get_cookie(
        '_ga=GA1.2.447610749.1465220820; _gat=1; ffo=true', 'ffo') == 'true', 'ffo=true'
    print("Looks like you know everything. It is time for 'Check'!")
